/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.maestros;

import DAO.ParametroDAO;
import Model.Parametro;
import Model.Vehiculo;
import Presenter.EnvioPedidoPresenter;
import Presenter.VehiculoPresenter;
import Principals.Utils;
import Principals.Validadores;
import View.components.Index;
import java.util.List;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/*
 *
 * @author walter
 */
public class Frm_BuscarVehiculo extends javax.swing.JDesktopPane {

    private DefaultTableModel mdlBuscarVehiculo;
    /**
     * Creates new form Frm_BuscarVehiculo
     */
    Validadores val = new Validadores();

    public Frm_BuscarVehiculo() {
        initComponents();
        EnvioPedidoPresenter.actualizarEnvioPedido();
        
        val.desactivarAccionPegar(txtPlaca);
        tblBuscarVehiculo.getTableHeader().setReorderingAllowed(false);
        mdlBuscarVehiculo = new DefaultTableModel();

        //Cargar cbxTipoVehiculo
        cbxTipoVehiculo.addItem("Todos");
        List<Parametro> lstTipoVehiculo = ParametroDAO.getTipoVehiculos();
        for (Parametro p : lstTipoVehiculo) {
            cbxTipoVehiculo.addItem(p);
        }

        //Cargar cbxEstado
        String[] lstEstados = Utils.getEstadosMaestro();
        cbxEstado.addItem("Todos");
        for (int i = 1; i < lstEstados.length; i++) {
            cbxEstado.addItem(lstEstados[i]);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar2 = new javax.swing.JToolBar();
        btnToolNuevo = new javax.swing.JButton();
        btnToolModificar = new javax.swing.JButton();
        btnToolAlmacenar = new javax.swing.JButton();
        btnToolEliminar = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        btnToolLimpar = new javax.swing.JButton();
        btnToolBuscar = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        btnToolCancelar = new javax.swing.JButton();
        pnlBuscarEmpleado = new javax.swing.JPanel();
        lblTipoVehiculo = new javax.swing.JLabel();
        lblPlaca = new javax.swing.JLabel();
        txtPlaca = new javax.swing.JTextField();
        cbxTipoVehiculo = new javax.swing.JComboBox();
        lblAnhoFabricacion = new javax.swing.JLabel();
        btnBuscar = new javax.swing.JToggleButton();
        cbxAnhoFabricacion = new com.toedter.calendar.JYearChooser();
        lblEstado = new javax.swing.JLabel();
        cbxEstado = new javax.swing.JComboBox();
        pnlResultadosEmpleado = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblBuscarVehiculo = new javax.swing.JTable();

        jToolBar2.setFloatable(false);
        jToolBar2.setBorderPainted(false);

        btnToolNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Nuevo.png"))); // NOI18N
        btnToolNuevo.setFocusable(false);
        btnToolNuevo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolNuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolNuevoActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolNuevo);

        btnToolModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Editar.png"))); // NOI18N
        btnToolModificar.setFocusable(false);
        btnToolModificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolModificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolModificarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolModificar);

        btnToolAlmacenar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Guardar.png"))); // NOI18N
        btnToolAlmacenar.setEnabled(false);
        btnToolAlmacenar.setFocusable(false);
        btnToolAlmacenar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolAlmacenar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolAlmacenar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolAlmacenarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolAlmacenar);

        btnToolEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Eliminar.png"))); // NOI18N
        btnToolEliminar.setFocusable(false);
        btnToolEliminar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolEliminar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolEliminarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolEliminar);
        jToolBar2.add(jSeparator4);

        btnToolLimpar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Limpiar.png"))); // NOI18N
        btnToolLimpar.setFocusable(false);
        btnToolLimpar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolLimpar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolLimparActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolLimpar);

        btnToolBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Buscar.png"))); // NOI18N
        btnToolBuscar.setEnabled(false);
        btnToolBuscar.setFocusable(false);
        btnToolBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolBuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolBuscarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolBuscar);
        jToolBar2.add(jSeparator3);

        btnToolCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Cancelar.png"))); // NOI18N
        btnToolCancelar.setToolTipText("");
        btnToolCancelar.setEnabled(false);
        btnToolCancelar.setFocusable(false);
        btnToolCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolCancelarActionPerformed(evt);
            }
        });
        jToolBar2.add(btnToolCancelar);

        pnlBuscarEmpleado.setBorder(javax.swing.BorderFactory.createTitledBorder("Búsqueda de vehículos"));

        lblTipoVehiculo.setText("Tipo de Vehículo");

        lblPlaca.setText("Placa:");

        txtPlaca.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtPlacaKeyTyped(evt);
            }
        });

        lblAnhoFabricacion.setText("Año de fabricación máx.:");

        btnBuscar.setText("Buscar");
        btnBuscar.setAutoscrolls(true);
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        lblEstado.setText("Estado:");

        javax.swing.GroupLayout pnlBuscarEmpleadoLayout = new javax.swing.GroupLayout(pnlBuscarEmpleado);
        pnlBuscarEmpleado.setLayout(pnlBuscarEmpleadoLayout);
        pnlBuscarEmpleadoLayout.setHorizontalGroup(
            pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlBuscarEmpleadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlBuscarEmpleadoLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(btnBuscar))
                    .addGroup(pnlBuscarEmpleadoLayout.createSequentialGroup()
                        .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblTipoVehiculo)
                            .addComponent(lblAnhoFabricacion))
                        .addGap(18, 18, 18)
                        .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbxTipoVehiculo, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbxAnhoFabricacion, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblEstado))
                        .addGap(24, 24, 24)
                        .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtPlaca, javax.swing.GroupLayout.DEFAULT_SIZE, 157, Short.MAX_VALUE)
                            .addComponent(cbxEstado, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGap(5, 5, 5))
        );
        pnlBuscarEmpleadoLayout.setVerticalGroup(
            pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlBuscarEmpleadoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlBuscarEmpleadoLayout.createSequentialGroup()
                        .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblPlaca)
                            .addComponent(txtPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblEstado))
                        .addGap(35, 35, 35)
                        .addComponent(btnBuscar))
                    .addGroup(pnlBuscarEmpleadoLayout.createSequentialGroup()
                        .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblTipoVehiculo)
                            .addComponent(cbxTipoVehiculo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pnlBuscarEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cbxAnhoFabricacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblAnhoFabricacion)))))
        );

        pnlResultadosEmpleado.setBorder(javax.swing.BorderFactory.createTitledBorder("Resultados"));

        tblBuscarVehiculo.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "ID", "Placa", "Tipo de vehículo", "Año de fabricación", "Estado"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, true
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(tblBuscarVehiculo);

        javax.swing.GroupLayout pnlResultadosEmpleadoLayout = new javax.swing.GroupLayout(pnlResultadosEmpleado);
        pnlResultadosEmpleado.setLayout(pnlResultadosEmpleadoLayout);
        pnlResultadosEmpleadoLayout.setHorizontalGroup(
            pnlResultadosEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlResultadosEmpleadoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlResultadosEmpleadoLayout.setVerticalGroup(
            pnlResultadosEmpleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlResultadosEmpleadoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pnlResultadosEmpleado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlBuscarEmpleado, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(pnlBuscarEmpleado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlResultadosEmpleado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cambiarVista(JDesktopPane panel) {
        ((Index) (this.getTopLevelAncestor())).changeDesktopPane(panel);
    }

    private void btnToolNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolNuevoActionPerformed
        cambiarVista(new Frm_RegistrarVehiculo()); // <---------------------------- ESTO SE DEBE CAMBIAR
    }//GEN-LAST:event_btnToolNuevoActionPerformed

    private void btnToolModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolModificarActionPerformed
        int i = this.tblBuscarVehiculo.getSelectedRow();
        if (i != -1) {
            int idVehiculo = Integer.parseInt(this.tblBuscarVehiculo.getValueAt(i, 0).toString());
            cambiarVista(new Frm_ModificarVehiculo(idVehiculo));
        } else {
            JOptionPane.showMessageDialog(this, "No se ha seleccionado ningún vehículo.");
        }
    }//GEN-LAST:event_btnToolModificarActionPerformed

    private void btnToolBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolBuscarActionPerformed
    }//GEN-LAST:event_btnToolBuscarActionPerformed

    private void btnToolEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolEliminarActionPerformed
        int i = this.tblBuscarVehiculo.getSelectedRow();
        if (i != -1) {
            int respuesta = JOptionPane.showConfirmDialog(this, "¿Desea eliminar este registro?", "Eliminar", JOptionPane.OK_CANCEL_OPTION);
            switch (respuesta) {
                case JOptionPane.OK_OPTION:
                    //Eliminar vehiculo
                    String est = this.tblBuscarVehiculo.getValueAt(i, 4).toString();
                    if (!est.equals("En ruta")) {
                        int idVehiculo = Integer.parseInt(this.tblBuscarVehiculo.getValueAt(i, 0).toString());
                        Vehiculo v = VehiculoPresenter.cargarVehiculo(idVehiculo);
                        VehiculoPresenter.eliminarVehiculo(v);

                        //Actualizar tabla de resultados
                        String placa = txtPlaca.getText();
                        Parametro tipo_vehiculo = null;
                        if (!cbxTipoVehiculo.getSelectedItem().equals("Todos")) {
                            tipo_vehiculo = (Parametro) cbxTipoVehiculo.getSelectedItem();
                        }
                        int anho = cbxAnhoFabricacion.getYear();
                        int estado = cbxEstado.getSelectedIndex();

                        List<Vehiculo> lstVehiculo = VehiculoPresenter.buscarVehiculo(placa, tipo_vehiculo, anho, estado);

                        mdlBuscarVehiculo.setNumRows(0);
                        mdlBuscarVehiculo = (DefaultTableModel) tblBuscarVehiculo.getModel();

                        for (int j = 0; j < lstVehiculo.size(); j++) {
                            Vehiculo v2 = lstVehiculo.get(j);
                            Object[] row = new Object[]{v2.getIdVehiculo(), v2.getPlaca(), v2.getTipoVehiculo(), v2.getAnho(),
                                Utils.getEstadoMaestro(v2.getEstado())};
                            mdlBuscarVehiculo.insertRow(j, row);
                        }
                        tblBuscarVehiculo.setVisible(true);
                        JOptionPane.showMessageDialog(this, "Se elimininó el registro seleccionado.");
                    } else {
                        JOptionPane.showMessageDialog(this, "No se puede eliminar este vehículo porque está en ruta.");
                    }

                    break;
                case JOptionPane.CANCEL_OPTION:
                    break;
            }

        } else {
            JOptionPane.showMessageDialog(this, "No se ha seleccionado ningún vehículo.");
        }
    }//GEN-LAST:event_btnToolEliminarActionPerformed

    private void btnToolCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolCancelarActionPerformed
        cambiarVista(new Frm_BuscarVehiculo());
    }//GEN-LAST:event_btnToolCancelarActionPerformed

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
        String placa = txtPlaca.getText();
        Parametro tipo_vehiculo = null;
        if (!cbxTipoVehiculo.getSelectedItem().equals("Todos")) {
            tipo_vehiculo = (Parametro) cbxTipoVehiculo.getSelectedItem();
        }

        int anho = cbxAnhoFabricacion.getYear();
        int estado = cbxEstado.getSelectedIndex();

        List<Vehiculo> lstVehiculo = VehiculoPresenter.buscarVehiculo(placa, tipo_vehiculo, anho, estado);

        mdlBuscarVehiculo.setNumRows(0);
        mdlBuscarVehiculo = (DefaultTableModel) tblBuscarVehiculo.getModel();

        for (int i = 0; i < lstVehiculo.size(); i++) {
            Vehiculo v = lstVehiculo.get(i);
            Object[] row = new Object[]{v.getIdVehiculo(), v.getPlaca(), v.getTipoVehiculo(),
                v.getAnho(), Utils.getEstadoMaestro(v.getEstado())};
            mdlBuscarVehiculo.insertRow(i, row);
        }
        tblBuscarVehiculo.setVisible(true);

        //limpiar();
        JOptionPane.showMessageDialog(this, "Se encontró " + mdlBuscarVehiculo.getRowCount() + " conincidencia(s)");
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void btnToolAlmacenarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolAlmacenarActionPerformed
    }//GEN-LAST:event_btnToolAlmacenarActionPerformed

    private void btnToolLimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolLimparActionPerformed
        cbxTipoVehiculo.setSelectedIndex(2);
        cbxAnhoFabricacion.setYear(2003);
        txtPlaca.setText("");
        mdlBuscarVehiculo.setNumRows(0);
        mdlBuscarVehiculo = (DefaultTableModel) tblBuscarVehiculo.getModel();
    }//GEN-LAST:event_btnToolLimparActionPerformed

    private void txtPlacaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPlacaKeyTyped
        val.validaPlaca(evt);
        val.validaMaxSize(evt, 7, txtPlaca.getText());
    }//GEN-LAST:event_txtPlacaKeyTyped
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton btnBuscar;
    private javax.swing.JButton btnToolAlmacenar;
    private javax.swing.JButton btnToolBuscar;
    private javax.swing.JButton btnToolCancelar;
    private javax.swing.JButton btnToolEliminar;
    private javax.swing.JButton btnToolLimpar;
    private javax.swing.JButton btnToolModificar;
    private javax.swing.JButton btnToolNuevo;
    private com.toedter.calendar.JYearChooser cbxAnhoFabricacion;
    private javax.swing.JComboBox cbxEstado;
    private javax.swing.JComboBox cbxTipoVehiculo;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JLabel lblAnhoFabricacion;
    private javax.swing.JLabel lblEstado;
    private javax.swing.JLabel lblPlaca;
    private javax.swing.JLabel lblTipoVehiculo;
    private javax.swing.JPanel pnlBuscarEmpleado;
    private javax.swing.JPanel pnlResultadosEmpleado;
    private javax.swing.JTable tblBuscarVehiculo;
    private javax.swing.JTextField txtPlaca;
    // End of variables declaration//GEN-END:variables
}
